home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1999 / MacHack 1999.toast / The Hacks / NetPokerForMacOSX_Server / HoldEmHigh / AppDelegate.m < prev    next >
Encoding:
Text File  |  1999-06-26  |  1.9 KB  |  76 lines

  1. #import "AppDelegate.h"
  2. #import "IRCTask.h"
  3.  
  4. @implementation AppDelegate
  5.  
  6. - (NSString *)userName {
  7.    return [[NSUserDefaults standardUserDefaults] objectForKey:@"Name"];
  8. }
  9.  
  10. - (PokerTable *)currentTable
  11. {
  12.     return currentTable;
  13. }
  14.  
  15.  
  16. - (id)sharedInstanceOfClassName:(NSString *)name
  17. {
  18.     id obj = nil;
  19.     NSString *path = [[NSBundle mainBundle] pathForResource:name ofType:@"bundle"];
  20.     if (path) {
  21.         NSBundle *b = [[NSBundle allocWithZone:NULL] initWithPath:path];
  22.         if ((b != nil) && ([b principalClass] !=NULL)) {
  23.                 obj = [[b principalClass] sharedInstance];
  24.         } else NSLog(@"Can't Load %@!\n", path);
  25.     } else NSLog(@"Couldn't find %@ bundle!\n",name);
  26.     return obj;
  27. }
  28.  
  29. - (IBAction)showPreferences:(id)sender {
  30.     [[self sharedInstanceOfClassName:@"Preferences"] showWindow:self];
  31. }
  32.  
  33. - (void)setCurrentTable:(PokerTable *)table;
  34. {
  35.      currentTable = table;
  36. }
  37.  
  38. - (void)newTable:(id)sender
  39. {
  40.     currentTable = [[NSDocumentController sharedDocumentController] openUntitledDocumentOfType:@"Poker" display:YES];
  41.     [currentTable addPlayer:[self userName] cash:5000];
  42.  
  43. }
  44.  
  45. - (IBAction)goOnVacation:sender {
  46.     [[IRCTask sharedIRCTask] goOnVacation];
  47. }
  48.  
  49. - (IBAction)returnFromVacation:sender {
  50.     [[IRCTask sharedIRCTask] returnFromVacation];
  51. }
  52.  
  53. - (void)applicationDidFinishLaunching:(NSNotification *)notification {
  54.     currentTable = [[[NSDocumentController sharedDocumentController] documents] objectAtIndex:0];
  55.     [[IRCTask sharedIRCTask] makeIRCConnection:currentTable];
  56.     [[IRCTask sharedIRCTask] joinTable];
  57. }
  58.  
  59. - (void)applicationWillFinishLaunching:(NSNotification *)notification {
  60.     NSMutableDictionary *dict = [NSMutableDictionary dictionary];
  61.     [dict setObject:@"deadhead" forKey:@"Name"];
  62.     [[NSUserDefaults standardUserDefaults] registerDefaults:dict];
  63. }
  64.  
  65. - (void)leaveTable:(id)sender {
  66.     [[IRCTask sharedIRCTask] leaveTable];
  67. }
  68.  
  69. - (void)joinTable:(id)sender {
  70.     [[IRCTask sharedIRCTask] joinTable];
  71. }
  72.  
  73.  
  74.  
  75. @end
  76.